.class public Lcom/brixd/niceapp/control/HtmlTextView;
.super Landroid/widget/TextView;
.source "HtmlTextView.java"


# instance fields
.field dontConsumeNonUrlClicks:Z

.field linkHit:Z

.field private mEllipsis:Ljava/lang/String;

.field private mNeedsResize:Z


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .registers 3
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 22
    invoke-direct {p0, p1}, Landroid/widget/TextView;-><init>(Landroid/content/Context;)V

    .line 15
    const-string v0, "..."

    iput-object v0, p0, Lcom/brixd/niceapp/control/HtmlTextView;->mEllipsis:Ljava/lang/String;

    .line 16
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/brixd/niceapp/control/HtmlTextView;->mNeedsResize:Z

    .line 18
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/brixd/niceapp/control/HtmlTextView;->dontConsumeNonUrlClicks:Z

    .line 23
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .registers 4
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "attrs"    # Landroid/util/AttributeSet;

    .prologue
    .line 26
    invoke-direct {p0, p1, p2}, Landroid/widget/TextView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 15
    const-string v0, "..."

    iput-object v0, p0, Lcom/brixd/niceapp/control/HtmlTextView;->mEllipsis:Ljava/lang/String;

    .line 16
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/brixd/niceapp/control/HtmlTextView;->mNeedsResize:Z

    .line 18
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/brixd/niceapp/control/HtmlTextView;->dontConsumeNonUrlClicks:Z

    .line 27
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
    .registers 5
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "attrs"    # Landroid/util/AttributeSet;
    .param p3, "defStyle"    # I

    .prologue
    .line 30
    invoke-direct {p0, p1, p2, p3}, Landroid/widget/TextView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    .line 15
    const-string v0, "..."

    iput-object v0, p0, Lcom/brixd/niceapp/control/HtmlTextView;->mEllipsis:Ljava/lang/String;

    .line 16
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/brixd/niceapp/control/HtmlTextView;->mNeedsResize:Z

    .line 18
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/brixd/niceapp/control/HtmlTextView;->dontConsumeNonUrlClicks:Z

    .line 31
    return-void
.end method


# virtual methods
.method protected onLayout(ZIIII)V
    .registers 10
    .param p1, "changed"    # Z
    .param p2, "left"    # I
    .param p3, "top"    # I
    .param p4, "right"    # I
    .param p5, "bottom"    # I

    .prologue
    .line 66
    if-nez p1, :cond_6

    iget-boolean v2, p0, Lcom/brixd/niceapp/control/HtmlTextView;->mNeedsResize:Z

    if-eqz v2, :cond_23

    .line 67
    :cond_6
    sub-int v2, p4, p2

    invoke-virtual {p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getCompoundPaddingLeft()I

    move-result v3

    sub-int/2addr v2, v3

    invoke-virtual {p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getCompoundPaddingRight()I

    move-result v3

    sub-int v1, v2, v3

    .line 68
    .local v1, "widthLimit":I
    sub-int v2, p5, p3

    invoke-virtual {p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getCompoundPaddingBottom()I

    move-result v3

    sub-int/2addr v2, v3

    invoke-virtual {p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getCompoundPaddingTop()I

    move-result v3

    sub-int v0, v2, v3

    .line 69
    .local v0, "heightLimit":I
    invoke-virtual {p0, v1, v0}, Lcom/brixd/niceapp/control/HtmlTextView;->resizeText(II)V

    .line 71
    .end local v0    # "heightLimit":I
    .end local v1    # "widthLimit":I
    :cond_23
    invoke-super/range {p0 .. p5}, Landroid/widget/TextView;->onLayout(ZIIII)V

    .line 72
    return-void
.end method

.method protected onSizeChanged(IIII)V
    .registers 6
    .param p1, "w"    # I
    .param p2, "h"    # I
    .param p3, "oldw"    # I
    .param p4, "oldh"    # I

    .prologue
    .line 56
    if-ne p1, p3, :cond_4

    if-eq p2, p4, :cond_7

    .line 57
    :cond_4
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/brixd/niceapp/control/HtmlTextView;->mNeedsResize:Z

    .line 59
    :cond_7
    return-void
.end method

.method public onTouchEvent(Landroid/view/MotionEvent;)Z
    .registers 4
    .param p1, "event"    # Landroid/view/MotionEvent;

    .prologue
    .line 35
    const/4 v1, 0x0

    iput-boolean v1, p0, Lcom/brixd/niceapp/control/HtmlTextView;->linkHit:Z

    .line 36
    invoke-super {p0, p1}, Landroid/widget/TextView;->onTouchEvent(Landroid/view/MotionEvent;)Z

    move-result v0

    .line 38
    .local v0, "res":Z
    iget-boolean v1, p0, Lcom/brixd/niceapp/control/HtmlTextView;->dontConsumeNonUrlClicks:Z

    if-eqz v1, :cond_d

    .line 39
    iget-boolean v0, p0, Lcom/brixd/niceapp/control/HtmlTextView;->linkHit:Z

    .line 40
    .end local v0    # "res":Z
    :cond_d
    return v0
.end method

.method public resizeText()V
    .registers 5

    .prologue
    .line 79
    invoke-virtual {p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getHeight()I

    move-result v2

    invoke-virtual {p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getPaddingBottom()I

    move-result v3

    sub-int/2addr v2, v3

    invoke-virtual {p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getPaddingTop()I

    move-result v3

    sub-int v0, v2, v3

    .line 80
    .local v0, "heightLimit":I
    invoke-virtual {p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getWidth()I

    move-result v2

    invoke-virtual {p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getPaddingLeft()I

    move-result v3

    sub-int/2addr v2, v3

    invoke-virtual {p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getPaddingRight()I

    move-result v3

    sub-int v1, v2, v3

    .line 81
    .local v1, "widthLimit":I
    invoke-virtual {p0, v1, v0}, Lcom/brixd/niceapp/control/HtmlTextView;->resizeText(II)V

    .line 82
    return-void
.end method

.method public resizeText(II)V
    .registers 19
    .param p1, "width"    # I
    .param p2, "height"    # I

    .prologue
    .line 90
    invoke-virtual/range {p0 .. p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getText()Ljava/lang/CharSequence;

    move-result-object v2

    .line 92
    .local v2, "text":Ljava/lang/CharSequence;
    if-eqz v2, :cond_10

    invoke-interface {v2}, Ljava/lang/CharSequence;->length()I

    move-result v4

    if-eqz v4, :cond_10

    if-lez p2, :cond_10

    if-gtz p1, :cond_11

    .line 123
    :cond_10
    :goto_10
    return-void

    .line 97
    :cond_11
    invoke-virtual/range {p0 .. p0}, Lcom/brixd/niceapp/control/HtmlTextView;->getPaint()Landroid/text/TextPaint;

    move-result-object v3

    .line 98
    .local v3, "textPaint":Landroid/text/TextPaint;
    new-instance v1, Landroid/text/StaticLayout;

    sget-object v5, Landroid/text/Layout$Alignment;->ALIGN_NORMAL:Landroid/text/Layout$Alignment;

    const/high16 v6, 0x3fa00000

    const/4 v7, 0x0

    const/4 v8, 0x1

    move/from16 v4, p1

    invoke-direct/range {v1 .. v8}, Landroid/text/StaticLayout;-><init>(Ljava/lang/CharSequence;Landroid/text/TextPaint;ILandroid/text/Layout$Alignment;FFZ)V

    .line 101
    .local v1, "layout":Landroid/text/StaticLayout;
    invoke-virtual {v1}, Landroid/text/StaticLayout;->getLineCount()I

    move-result v11

    .line 102
    .local v11, "lineCount":I
    invoke-virtual {v1}, Landroid/text/StaticLayout;->getHeight()I

    move-result v4

    div-int v15, v4, v11

    .line 103
    .local v15, "textHeight":I
    div-int v13, p2, v15

    .line 105
    .local v13, "maxLines":I
    if-le v11, v13, :cond_83

    .line 106
    add-int/lit8 v4, v13, -0x1

    invoke-virtual {v1, v4}, Landroid/text/StaticLayout;->getLineStart(I)I

    move-result v14

    .line 107
    .local v14, "start":I
    add-int/lit8 v4, v13, -0x1

    invoke-virtual {v1, v4}, Landroid/text/StaticLayout;->getLineEnd(I)I

    move-result v10

    .line 108
    .local v10, "end":I
    add-int/lit8 v4, v13, -0x1

    invoke-virtual {v1, v4}, Landroid/text/StaticLayout;->getLineWidth(I)F

    move-result v12

    .line 109
    .local v12, "lineWidth":F
    move-object/from16 v0, p0

    iget-object v4, v0, Lcom/brixd/niceapp/control/HtmlTextView;->mEllipsis:Ljava/lang/String;

    invoke-virtual {v3, v4}, Landroid/text/TextPaint;->measureText(Ljava/lang/String;)F

    move-result v9

    .line 112
    .local v9, "ellipseWidth":F
    :goto_4a
    move/from16 v0, p1

    int-to-float v4, v0

    add-float v5, v12, v9

    cmpg-float v4, v4, v5

    if-gez v4, :cond_64

    .line 113
    add-int/lit8 v10, v10, -0x1

    add-int/lit8 v4, v10, 0x1

    invoke-interface {v2, v14, v4}, Ljava/lang/CharSequence;->subSequence(II)Ljava/lang/CharSequence;

    move-result-object v4

    invoke-interface {v4}, Ljava/lang/CharSequence;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Landroid/text/TextPaint;->measureText(Ljava/lang/String;)F

    move-result v12

    goto :goto_4a

    .line 115
    :cond_64
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    const/4 v5, 0x0

    invoke-interface {v2, v5, v10}, Ljava/lang/CharSequence;->subSequence(II)Ljava/lang/CharSequence;

    move-result-object v5

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v4

    move-object/from16 v0, p0

    iget-object v5, v0, Lcom/brixd/niceapp/control/HtmlTextView;->mEllipsis:Ljava/lang/String;

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    move-object/from16 v0, p0

    invoke-virtual {v0, v4}, Lcom/brixd/niceapp/control/HtmlTextView;->setText(Ljava/lang/CharSequence;)V

    .line 118
    .end local v9    # "ellipseWidth":F
    .end local v10    # "end":I
    .end local v12    # "lineWidth":F
    .end local v14    # "start":I
    :cond_83
    move-object/from16 v0, p0

    invoke-virtual {v0, v13}, Lcom/brixd/niceapp/control/HtmlTextView;->setMaxLines(I)V

    .line 121
    const/4 v4, 0x0

    move-object/from16 v0, p0

    iput-boolean v4, v0, Lcom/brixd/niceapp/control/HtmlTextView;->mNeedsResize:Z

    goto :goto_10
.end method

.method public setTextViewHtml(Ljava/lang/String;)V
    .registers 4
    .param p1, "html"    # Ljava/lang/String;

    .prologue
    .line 45
    invoke-static {p1}, Landroid/text/Html;->fromHtml(Ljava/lang/String;)Landroid/text/Spanned;

    move-result-object v0

    .line 46
    .local v0, "sequence":Ljava/lang/CharSequence;
    new-instance v1, Landroid/text/SpannableStringBuilder;

    invoke-direct {v1, v0}, Landroid/text/SpannableStringBuilder;-><init>(Ljava/lang/CharSequence;)V

    .line 47
    .local v1, "strBuilder":Landroid/text/SpannableStringBuilder;
    invoke-virtual {p0, v1}, Lcom/brixd/niceapp/control/HtmlTextView;->setText(Ljava/lang/CharSequence;)V

    .line 48
    return-void
.end method
